package com.firstresponder.activity;

import com.firstresponder.location.LocationService;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.ToggleButton;

public class LocationScreen extends  Activity{

	private static final String TAG = "FRLocationScreen";
	private TextView gpsLoc,gpsAcc,netLoc,netAcc,provider_view;
	private ToggleButton locationToggle;
	private Intent locationServiceIntent;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		Log.i(TAG, "OnCreate Called");
		super.onCreate(savedInstanceState);
		//locationServiceIntent.setClassName("com.firstresponder", LocationService.class.getName());
		locationServiceIntent = new Intent(this, LocationService.class);
		setContentView(R.layout.locationscreen);
		gpsLoc = (TextView) findViewById(R.id.gps_loc_view);
		gpsAcc = (TextView) findViewById(R.id.gps_acc_view);
		netLoc = (TextView) findViewById(R.id.net_loc_view);
		netAcc = (TextView) findViewById(R.id.net_acc_view);
		provider_view = (TextView) findViewById(R.id.provider_view);
		locationToggle = (ToggleButton) findViewById(R.id.location_toggle);
		locationToggle.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if(locationToggle.isChecked()){
					startService(locationServiceIntent);
				}
				else{
					stopService(locationServiceIntent);
				}
				
			}
			
		});
		//LocationService.setMainActivity(this);
	}
	
	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
	}
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}
	
	public void UpdateGpsText(double loc, float acc, String provider){
		gpsLoc.setText("GPSLoc: " + Double.toString(loc));
		gpsAcc.setText("GPSAcc: " + Float.toString(acc));
//		gpsLoc.append(Double.toString(loc));
//		gpsAcc.append(Float.toString(acc));
		provider_view.setText("Provider: " + provider);
	}
	
	public void UpdateNetworkText(double loc, float acc){
		netLoc.setText("NETLoc: " + Double.toString(loc));
		netAcc.setText("NETAcc: " + Float.toString(acc));
//		netLoc.append(Double.toString(loc));
//		netAcc.append(Float.toString(acc));
	}
	

}
